class Vendor < ActiveRecord::Base
  has_many :purchases
  belongs_to :purchase
  has_many :products

  #得到供应商列表
  def self.findVendors vendor_number,vendor_name,state,pageBegin,pageEnd
    find(:all,:conditions => ['login_id like ? and company_name like ? and auditing_status like ?','%'+vendor_number+'%','%'+vendor_name+'%','%'+state+'%'],:offset=>pageBegin.to_i,:limit =>pageEnd.to_i)
  end

  def self.findByLoginId loginId
    find(:first,:conditions => ['login_id = ?',loginId])
  end
end
